//
//  HHInfoViewController.m
//  HHgitosc
//
//  Created by AHUAN on 16/3/22.
//  Copyright © 2016年 hjl. All rights reserved.
//

#import "HHInfoViewController.h"
#import "HHProject.h"
#import "HHHeaderView.h"

@interface HHInfoViewController ()

@end

static NSString * const HHInfoCellId = @"info";

@implementation HHInfoViewController

- (void)viewDidLoad{
    [super viewDidLoad];
    
    [self setupTableView];
    
}



- (void)setupTableView{
    
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:HHInfoCellId];
    
    self.tableView.backgroundColor = [UIColor whiteColor];
    
    // 设置头部
    HHHeaderView *headView = [[NSBundle mainBundle] loadNibNamed:@"HHHeaderView" owner:nil options:nil].lastObject;
    
    headView.project = self.project;
    headView.size = self.project.headerViewSize;
    
    self.tableView.tableHeaderView = headView;
    // self.tableView.tableHeaderView.size = self.project.headerViewSize;
   
    [self.tableView reloadData];
    
    // 设置尾部
    self.tableView.tableFooterView = [[UIView alloc] init];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 5;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:HHInfoCellId forIndexPath:indexPath];
    
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    if(indexPath.row == 0){
        
        cell.imageView.image = [UIImage imageNamed:@"projectDetails_owner"];
        NSString *text = @"拥有者";
        cell.textLabel.text = [NSString stringWithFormat:@"%@  %@", text, self.project.owner.name];
        
    } else if(indexPath.row == 1){
        
        cell.imageView.image = [UIImage imageNamed:@"projectDetails_readme"];
        cell.textLabel.text = @"Readme";
        
    } else if(indexPath.row == 2){
        
        cell.imageView.image = [UIImage imageNamed:@"projectDetails_code"];
        cell.textLabel.text = @"代码";
    } else if(indexPath.row == 3){
        
        cell.imageView.image = [UIImage imageNamed:@"projectDetails_issue"];
        cell.textLabel.text = @"问题";
        
    } else if(indexPath.row == 4){
        
        cell.imageView.image = [UIImage imageNamed:@"projectDetails_branch"];
        cell.textLabel.text = @"提交";
    }
    
    return cell;
}

@end
